<?php
/** An interface to the Hosting Reborn API pricing functions
 *
 * @package com\hostingreborn\api
 * @link https//api.hostingreborn.com/docs/functions/price/
 *
 * @author      Jon Cram <jon@hostingreborn.com>
 * @copyright   https://api.hostingreborn.com/code/copyright/
 * @license     https://api.hostingreborn.com/code/license/
 * @version     1.0
 *
 * $Date$
 * $Revision$
 *
 *
 */

require_once('HR_api.class.php');

class HR_priceApi extends HR_api {

    /***************************************************************************/
    /* Attributes                                                              */
    /***************************************************************************/

    /***************************************************************************/
    /* Constructors                                                            */
    /***************************************************************************/

    /***************************************************************************/
    /* Public methods                                                          */
    /***************************************************************************/

    /**
     * @link http://api.hostingreborn.com/docs/functions/price/get/
     *
     * @return array
     *
     */
    public function get() {
        return $this->read('price/get')->getCollection(array(
                '/price/storage' => 'storage',
                '/price/bandwidth' => 'bandwidth'
        ));
    }


    /**
     * @link http://api.hostingreborn.com/docs/functions/price/calculate/
     *
     * @param float $storageUsage in megabytes
     * @param float $bandwidthUsage in gigabytes
     * @param float $period in days
     * @return float
     */
    public function calculatePrice($storageUsage, $bandwidthUsage, $period) {
        $queryString = http_build_query(array(
                'storage_usage' => $storageUsage,
                'bandwidth_usage' => $bandwidthUsage,
                'period' => $period
        ));

        return $this->read('price/calculate/?'.$queryString)->getValue('/price');
    }

    /***************************************************************************/
    /* Private methods                                                         */
    /***************************************************************************/

}

?>